package com.szxy.miaosha.dao;

import com.szxy.miaosha.domain.OrderInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

/**
 * @Author:zwer
 * @Date:2020/9/9 21:52
 * @Description:com.szxy.miaosha.dao
 * @Version:1.0
 **/
@Mapper
public interface OrderInfoDao {

    /**
     * 添加订单详情, 并返回订单详情的 ID
     *
     * @param orderInfo
     * @return
     */
    @Insert("insert into order_info(user_id, goods_id, goods_name, goods_count, goods_price\n" +
            ",order_channel, delivery_addrId, status, create_date) values(#{userId}, #{goodsId}\n" +
            ",#{goodsName}, #{goodsCount}, #{goodsPrice}, #{orderChannel}, #{deliveryAddrId}, #{status}\n" +
            ",#{createDate})")
    @SelectKey(keyColumn = "id", keyProperty = "id", resultType = Long.class, before = false, statement = "select last_insert_id()")
    Long insertOrderInfo(OrderInfo orderInfo);


}
